import { FormArticleCategory, FormArticleTag } from '@/components'
import { Row } from '@/components/FTable/components/search'
import dayjs from 'dayjs'
import { shallowRef } from 'vue'

/*
 * @Author: fhw
 * @Date: 2022-07-10 15:15:29
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-02-03 17:15:34
 * @Description:
 */
export const columns: Rantion.TableColumns[] = [
	{
		title: '文章标题',
		key: 'title',
		dataIndex: 'title',
		required: true,
		align: 'center',
		width: 200,
	},
	{
		title: '标签',
		key: 'tags',
		dataIndex: 'tags',
		required: true,
		align: 'center',
		width: 200,
		customRender: ({ record }: Rantion.RableSlotScope) => record.tags.join('，'),
	},
	{
		title: '分类',
		dataIndex: 'category',
		key: 'category',
		required: true,
		align: 'center',
		width: 200,
	},
	{
		title: '发布者',
		dataIndex: 'username',
		key: 'username',
		required: true,
		align: 'center',
		width: 200,
	},
	{
		title: '封面',
		dataIndex: 'imageUrl',
		key: 'imageUrl',
		required: true,
		align: 'center',
		width: 80,
		customRender: ({ record }: Rantion.RableSlotScope) => {
			return <a-image src={record.imageUrl} />
		},
	},
	{
		title: '阅读数',
		dataIndex: 'read',
		key: 'read',
		required: true,
		align: 'center',
		width: 200,
	},
	{
		title: '点赞数',
		dataIndex: 'thumbUp',
		key: 'thumbUp',
		required: true,
		align: 'center',
		width: 200,
	},
	{
		title: '创建时间',
		dataIndex: 'createDate',
		key: 'createDate',
		required: true,
		align: 'center',
		width: 200,
		customRender: ({ record }: Rantion.RableSlotScope) => {
			return dayjs(record.createDate).format('YYYY-MM-DD HH:mm:ss')
		},
	},
	{
		title: '操作',
		dataIndex: 'action',
		key: 'action',
		align: 'center',
		slots: {
			customRender: 'actionRender',
		},
		width: 200,
		fixed: 'right',
	},
]
export const rows: Array<Row> = [
	{
		title: '标题',
		key: 'title',
		component: 'a-input',
	},
	{
		title: '标签',
		key: 'tags',
		component: shallowRef(FormArticleTag),
	},
	{
		title: '分类',
		key: 'category',
		component: shallowRef(FormArticleCategory),
	},
	{
		title: '时间',
		key: 'date',
		component: 'a-range-picker',
		props: {
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
		},
	},
]
